package hello

import (
	"context"
	"goods_svc/goods"

	"api/internal/svc"
	"api/internal/types"

	"github.com/zeromicro/go-zero/core/logx"
)

type CreateActivityLogic struct {
	logx.Logger
	ctx    context.Context
	svcCtx *svc.ServiceContext
}

func NewCreateActivityLogic(ctx context.Context, svcCtx *svc.ServiceContext) *CreateActivityLogic {
	return &CreateActivityLogic{
		Logger: logx.WithContext(ctx),
		ctx:    ctx,
		svcCtx: svcCtx,
	}
}

func (l *CreateActivityLogic) CreateActivity(req *types.CreateActivityRequest) (resp *types.Response, err error) {
	// todo: add your logic here and delete this line

	activity, err := l.svcCtx.GoodsRpc.CreateActivity(l.ctx, &goods.CreateActivityRequest{
		ActivityName: req.ActivityName,
		Address:      req.Address,
		Time:         req.Time,
		Name:         req.Name,
	})
	if err != nil {
		return &types.Response{
			Message: err.Error(),
			Data:    nil,
			Code:    500,
		}, nil
	}

	return &types.Response{
		Message: "活动信息创建成功",
		Data:    activity,
		Code:    200,
	}, nil
}
